package com.xuhai.movie.controller;

import com.xuhai.movie.bean.Userinfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author PangJunjie
 * @Date 2022/4/20/020
 */
@Component
public abstract class AbstractController {

    @Autowired
    private HttpServletRequest request;

    @Autowired
    private ServletContext context;

    public Userinfo getLoginUser(){
        return (Userinfo) context.getAttribute(request.getHeader("token"));
    }
}
